package com.ruoyi.nucleicacid.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.nucleicacid.domain.Timeout;
import com.ruoyi.nucleicacid.service.ITimeoutService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 核酸任务超时Controller
 * 
 * @author ruoyi
 * @date 2022-10-18
 */
@RestController
@RequestMapping("/nucleicacid/timeout")
public class TimeoutController extends BaseController
{
    @Autowired
    private ITimeoutService timeoutService;

    /**
     * 查询核酸任务超时列表
     */
    @PreAuthorize("@ss.hasPermi('nucleicacid:timeout:list')")
    @GetMapping("/list")
    public TableDataInfo list(Timeout timeout)
    {
        startPage();
        List<Timeout> list = timeoutService.selectTimeoutList(timeout);
        return getDataTable(list);
    }

    /**
     * 导出核酸任务超时列表
     */
    @PreAuthorize("@ss.hasPermi('nucleicacid:timeout:export')")
    @Log(title = "核酸任务超时", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Timeout timeout)
    {
        List<Timeout> list = timeoutService.selectTimeoutList(timeout);
        ExcelUtil<Timeout> util = new ExcelUtil<Timeout>(Timeout.class);
        util.exportExcel(response, list, "核酸任务超时数据");
    }

    /**
     * 获取核酸任务超时详细信息
     */
    @PreAuthorize("@ss.hasPermi('nucleicacid:timeout:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(timeoutService.selectTimeoutById(id));
    }

    /**
     * 新增核酸任务超时
     */
    @PreAuthorize("@ss.hasPermi('nucleicacid:timeout:add')")
    @Log(title = "核酸任务超时", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Timeout timeout)
    {
        return toAjax(timeoutService.insertTimeout(timeout));
    }

    /**
     * 修改核酸任务超时
     */
    @PreAuthorize("@ss.hasPermi('nucleicacid:timeout:edit')")
    @Log(title = "核酸任务超时", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Timeout timeout)
    {
        return toAjax(timeoutService.updateTimeout(timeout));
    }

    /**
     * 删除核酸任务超时
     */
    @PreAuthorize("@ss.hasPermi('nucleicacid:timeout:remove')")
    @Log(title = "核酸任务超时", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(timeoutService.deleteTimeoutByIds(ids));
    }
}
